﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace XEvents.Library
{
    internal struct dm_xe_session_target
    {
        internal string event_session_address;
        internal string target_name;
        internal Guid target_package_guid;
        internal Int64 execution_count;
        internal Int64 execution_duration_ms;
        internal string target_data;

        internal dm_xe_session_target(SqlDataReader dr)
        {
            event_session_address = (dr["event_session_address"] == DBNull.Value ? string.Empty : dr["event_session_address"]).ToString();
            target_name = (dr["target_name"] == DBNull.Value ? string.Empty : dr["target_name"]).ToString();
            Utilities.IsGuid((dr["target_package_guid"] == DBNull.Value ? string.Empty : dr["target_package_guid"]).ToString(), out target_package_guid);
            Int64.TryParse((dr["execution_count"] == DBNull.Value ? "-1" : dr["execution_count"]).ToString(), out execution_count);
            Int64.TryParse((dr["execution_duration_ms"] == DBNull.Value ? "-1" : dr["execution_duration_ms"]).ToString(), out execution_duration_ms);
            target_data = (dr["target_data"] == DBNull.Value ? string.Empty : dr["target_data"]).ToString();
        }
    }
}
